home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
msysjour
/
vol06
/
05
/
windos
/
mem.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-01
|
930b
|
40 lines
/* MEM.C */
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <time.h>
main(int argc, char *argv[])
{
char far *fp;
time_t t1, t2;
unsigned long bytes = 0;
unsigned long allocs = 0;
unsigned blksize = (argc < 2) ? 1024 : atoi(argv[1]);
time(&t1);
for (;;)
if ((fp = _fmalloc(blksize)) != 0)
{
_fmemset(fp, 0, blksize); // touch every byte
*fp = 'x';
fp[blksize-1] = 'y';
bytes += blksize;
allocs++;
if ((allocs % 100) == 0)
printf("%lu allocs, %lu bytes, %Fp, %lu seconds\n",
allocs, bytes, fp, time(&t2) - t1);
}
else
break;
time(&t2);
printf("Allocated %lu bytes, %lu allocs, %lu seconds\n",
bytes, allocs, t2 - t1);
return 0;
}